package com.qianfeng.zw.meilishuo.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.qianfeng.zw.meilishuo.R;
import com.qianfeng.zw.meilishuo.bean.FashPromote;
import com.qianfeng.zw.meilishuo.listener.OnItemClickLitener;
import com.qianfeng.zw.meilishuo.utils.ImageLoaderHelper;
import com.qianfeng.zw.meilishuo.vh.AppViewHolder;
import com.qianfeng.zw.meilishuo.widget.CircleImageView;

import java.util.List;

/**
 * @作 用:
 * @创 建 人: zhangwei
 * @日 期: 15/4/6 16:28
 * @修 改 人:
 * @日 期:
 */
public class FashPromoteAdapter extends RecyclerView.Adapter<FashPromoteAdapter.FashHotViewHolder> implements OnItemClickLitener {
    private List<FashPromote> fashPromotes;
    private DisplayImageOptions options;

    public FashPromoteAdapter(List<FashPromote> fashPromotes) {
        this.fashPromotes = fashPromotes;
        options = ImageLoaderHelper.getInstance().getDefaultDisplayImageOptions();
    }

    @Override
    public void onItemClick(View view, int position) {


    }

    public class FashHotViewHolder extends AppViewHolder {
        private TextView nameTv;
        private CircleImageView img;

        public FashHotViewHolder(View itemView, OnItemClickLitener onItemClickLitener) {
            super(itemView, onItemClickLitener);
            nameTv = (TextView) itemView.findViewById(R.id.fash_promote_name);
            img = (CircleImageView) itemView.findViewById(R.id.fash_promote_img);
        }
    }

    @Override
    public FashHotViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_home_fashpromote_layout, parent, false);
        FashHotViewHolder holder = new FashHotViewHolder(itemView, this);
        return holder;
    }

    @Override
    public void onBindViewHolder(FashHotViewHolder holder, int position) {
        FashPromote fashPromote = fashPromotes.get(position);
        ImageLoader.getInstance().displayImage(fashPromote.getImg(), holder.img, options);
        holder.nameTv.setText(fashPromote.getName());
    }

    @Override
    public int getItemCount() {
        return fashPromotes.size();
    }
}
